<template>
  <div class="app-container">
    <div class="app-title">
      <span>卡号财政处理</span>
    </div>
    <el-row :gutter="20">
      <el-col :span="8">
        <el-col :span="1">
          <i
            :class="[treeShow ? 'el-icon-s-fold treeI': 'el-icon-s-unfold treeI']"
            @click="toggerTree"
          />
        </el-col>
        <div class="tap-fillet">
          <el-radio-group
            v-model="activeName"
            style="margin-left:4rem; width:700px; height:15px; margin-top:-57px "
          >
            <el-radio-button
              label="0"
              name="waitWanage"
            >待处理</el-radio-button>
            <el-radio-button
              label="1"
              name="alreadyGenerate"
            >已生成</el-radio-button>
            <el-radio-button
              label="2"
              name="alreadyChange"
            >已变更</el-radio-button>
          </el-radio-group>
        </div>
      </el-col>
      <div class="filter-container">
        <el-col
          style="text-align:right;margin-top: -3px;"
          :span="16"
        >
          <el-button
            size="small"
            class="filter-item"
            style="margin-left: 10px;"
            type="primary"
            @click="Query"
          >
            查询
          </el-button>
          <el-button
            v-if="activeName === '0'"
            size="small"
            class="filter-item"
            style="margin-left: 10px;width:150px;"
            type="primary"
            :loading="generateBankDataLoading"
            @click="generateAndExportBankData"
          >
            生成并导出银行数据
          </el-button>
          <el-button
            v-if="activeName === '0'"
            size="small"
            class="filter-item"
            style="margin-left: 10px;width:100px;"
            type="primary"
            :loading="PersonnelLoading"
            @click="Personnel"
          >
            更新人事信息
          </el-button>
          <el-button
            v-if="activeName === '2'"
            size="small"
            class="filter-item"
            style="margin-left:10px;width:120px;"
            type="primary"
            :loading="UpdatePersonnelLoading"
            @click="UpdatePersonnel"
          >
            撤销更新人事更新
          </el-button>
        </el-col>
      </div>
    </el-row>
    <div>
      <div style="margin-left:166px; position:absolute; margin-top:-40px">
        <img
          style="width:16px; height:16px;"
          :src="Processedimg"
        >
      </div>
      <div style="margin-left:76px; position:absolute; margin-top:-40px">
        <img
          style="width:16px; height:16px;"
          :src="noUntreatedimg"
        >
      </div>
      <div style="margin-left:255px; position:absolute; margin-top:-40px">
        <img
          style="width:16px; height:16px;"
          :src="Untreatedimg"
        >
      </div>
    </div>
    <div
      ref="box"
      class="box"
    >
      <div
        class="left"
        :class="[isActive ? 'wid':'wids']"
      >
        <div
          :class="[treeShow ? 'treeShow' : 'treeNotShow']"
          :style="{'height' : treeHeight + 'px'}"
        >
          <AgencyTree
            class="agencyTree"
            @handleTreeQuery="handleTreeQuery"
          />
        </div>
      </div>
      <div
        v-show="Show"
        class="resize"
        title="收缩侧边栏"
      />
      <div
        class="mid"
        :class="[isActive ? 'mids': 'min']"
      >
        <cardNumberFinancialProcessNoSftpChildrenTable
          :key="timer"
          ref="chil"
          :tab-pane="activeName"
          @PersonnelCallBack="PersonnelCallBack()"
          @UpdatePersonnelCallBack="UpdatePersonnelCallBack()"
          @generateBankDataCallBack="generateBankDataCallBack"
        />
      </div>
      <Drag ref="icon" />

    </div>
  </div>
</template>

<script>
import cardNumberFinancialProcessNoSftpChildrenTable from '@/views/exceptionCardNumberManage/children/cardNumberFinancialProcessNoSftpChildren'
import AgencyTree from '@/components/tree/agencyTree'
import Drag from '@/components/Drag'
export default {
  name: 'CardNumberFinancialProcess',
  components: { cardNumberFinancialProcessNoSftpChildrenTable, AgencyTree, Drag },

  data() {
    return {
      treeHeight: null,
      Show: false,
      isActive: true,
      treeShow: false,
      PersonnelLoading: false,
      UpdatePersonnelLoading: false,
      generateBankDataLoading: false,
      timer: '',
      activeName: '0',
      exportLoading: false,
      noUntreatedimg: require('@/assets/images/select.png'),
      Untreatedimg: require('@/assets/images/processed.png'),
      Processedimg: require('@/assets/images/processed.png')
    }
  },
  watch: {
    activeName(val) {
      this.timer = new Date().getTime()
      if (val === '0') {
        this.Processedimg = require('@/assets/images/blueselect.png')
        this.noUntreatedimg = require('@/assets/images/select.png')
        this.Untreatedimg = require('@/assets/images/processed.png')
      } else if (val === '1') {
        this.Processedimg = require('@/assets/images/select.png')
        this.noUntreatedimg = require('@/assets/images/blueselect.png')
        this.Untreatedimg = require('@/assets/images/processed.png')
      } else {
        this.Processedimg = require('@/assets/images/blueselect.png')
        this.noUntreatedimg = require('@/assets/images/blueselect.png')
        this.Untreatedimg = require('@/assets/images/blue.png')
      }
    }
  },
  mounted() {
    this.dragController()
    this.getTeHeight()
  },
  beforeMount() {
    window.addEventListener('resize', this.getTeHeight)
  },
  created() {},
  methods: {
    getTeHeight() {
      this.treeHeight = window.innerHeight - 270
    },
    // 拖拽
    dragController() {
      this.$refs.icon.dragControllerDiv()
    },
    // 树显隐方法
    toggerTree() {
      this.treeShow = !this.treeShow
      this.isActive = !this.isActive
      this.Show = !this.Show
    },
    // 树方法
    handleTreeQuery(data) {
      this.$refs.chil.handleTree(data)
    },
    // 查询
    Query() {
      this.$refs.chil.query()
    },
    Personnel() {
      this.PersonnelLoading = true
      this.$refs.chil.updatePersonnel()
    },
    PersonnelCallBack() {
      this.PersonnelLoading = false
    },
    UpdatePersonnel() {
      this.UpdatePersonnelLoading = true
      this.$refs.chil.undoUpdatePersonnel()
    },
    UpdatePersonnelCallBack() {
      this.UpdatePersonnelLoading = false
    },
    generateAndExportBankData() {
      this.generateBankDataLoading = true
      this.$refs.chil.generateAndExportBankData()
    },
    generateBankDataCallBack() {
      this.generateBankDataLoading = false
    }
  }
}
</script>

<style  lang="scss" scoped>
@import "~@/styles/border.scss"; /*引入公共样式*/
.app-title {
  margin-bottom: 15px;
  height: 20px;
  border-bottom: 1px solid #dcdfe6;
}
</style>
